package o;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;
import android.text.TextUtils;
import com.huawei.android.app.ActivityManagerEx;
import java.util.List;

public class euv {
    public static boolean ॱ(Context context, String str) {
        if (context == null || TextUtils.isEmpty(str)) {
            return false;
        }
        ActivityManager activityManager = (ActivityManager) context.getSystemService("activity");
        List runningAppProcesses;
        if (activityManager != null) {
            runningAppProcesses = activityManager.getRunningAppProcesses();
        } else {
            runningAppProcesses = null;
        }
        if (r0 == null) {
            Logger.ˏ("ActivityUtils", "appProcess is null");
            return false;
        }
        for (RunningAppProcessInfo runningAppProcessInfo : r0) {
            Object obj;
            for (Object equals : runningAppProcessInfo.pkgList) {
                if (str.equals(equals)) {
                    obj = 1;
                    break;
                }
            }
            obj = null;
            if (obj != null && (runningAppProcessInfo.importance == 125 || runningAppProcessInfo.importance == 100)) {
                return true;
            }
        }
        return false;
    }

    public static boolean ˎ(Context context, String str) {
        if (!bmt.ॱ(context)) {
            Logger.ˎ("ActivityUtils", "no music playing, packageName: " + str);
            return false;
        } else if (ॱ(context, str)) {
            return true;
        } else {
            Logger.ˎ("ActivityUtils", "app is not running foreground service, packageName: " + str);
            return false;
        }
    }

    public static String ˊ() {
        try {
            String str = ActivityManagerEx.getLastResumedActivity().packageName;
            if (ActivityManagerEx.isInGameSpace(str)) {
                return str;
            }
        } catch (Throwable th) {
            Logger.ˎ("ActivityUtils", "can not get current running game: " + th.toString());
        }
        return null;
    }
}
